package oj;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author ：冯涛滔
 * @date ：Created in 2020-4-25 17:37
 * @description： 错误的
 * @modified By：
 * @version:
 */
public class Oj11 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int count = in.nextInt();
            int day = 0;
            int last = -1;
            boolean flag = true;
            for (int i = 0; i < count; i++) {
                List<Integer> list = new ArrayList<>();
                for (int j = 0; j < 4; j++) {
                    list.add(in.nextInt());
                }
                for (int j = 0; j <4 ; j++) {
                    Integer integer = list.get(j);
                    if(integer==1&&last!=j){
                        last = j;
                        day++;
                        flag = false;
                        break;
                    }
                }
                if(list.indexOf(1)!=-1&&flag){ //开放了但是不能去
                    last = -1;
                }
                flag = true;

            }
            System.out.println(day);
        }
    }
}
